# Maintainer: Leonidas Spyropoulos <artafinde@archlinux.org>
# Contributor: Patrick Ziegler <p.ziegler96@gmail.com>

pkgname=polybar
pkgver=3.7.0
pkgrel=1
pkgdesc="A fast and easy-to-use status bar"
arch=('loong64' 'x86_64')
url="https://github.com/polybar/polybar"
backup=("etc/polybar/config.ini")
license=("MIT")
depends=("libuv" "cairo" "xcb-util-image" "xcb-util-wm" "xcb-util-xrm" "xcb-util-cursor"
         "alsa-lib" "libpulse" "libmpdclient" "libnl" "jsoncpp" "curl")
makedepends=("cmake" "python" "pkg-config" "python-sphinx" "python-packaging" "i3-wm"
             "ninja" "git")
optdepends=("i3-wm: i3 module support")
source=("${pkgname}-${pkgver}.tar.gz::${url}/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.gz"
        "${pkgname}-${pkgver}.tar.gz.asc::${url}/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.gz.asc")
sha256sums=('b8e07aca94a013341b7d47ee548afe84f519113f202300565d4852885a11e91d'
            'SKIP')
validpgpkeys=('1D5791352D51A228D4DDDBA4521E5E03AEBCA1A7') # Patrick Ziegler <p.ziegler96@gmail.com>

prepare() {
  cd "${pkgname}-${pkgver}"
  # Broken tests from executing inside systemd-nspawn
  sed -i 's/is_async/DISABLED_is_async/' \
    tests/unit_tests/utils/process.cpp
}

build() {
  cd "${pkgname}-${pkgver}"
  cmake \
    -Bbuild \
    -GNinja \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DBUILD_DOC_HTML=OFF \
    -DBUILD_TESTS=ON \
    -DPYTHON_EXECUTABLE=/usr/bin/python3
  cmake --build build --verbose
}

check() {
  cd "${pkgname}-${pkgver}"
  ninja check -C build
}

package() {
  cd "${pkgname}-${pkgver}"
  DESTDIR="${pkgdir}" cmake --install build
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

# vim:set ft=sh sw=2 sts=2 et:
